#include <stdio.h>
#include <stdlib.h>
#include <string.h>

bool isSymmtryStr(char* str)
{
	if (*str == '\0')
		return false;

	char *p = str;
	char *q = str;

	while(*q != '\0'){
		q++;
	}

	q--;

	while(q > p)
	{
		if (*q != *p)
			break;
		q--;
		p++;
	}

	if (q >= p)
		return false;
	return true;
}


int findMaxSymmtryStr(char* str)
{
	if (*str == '\0')
		return 0;
	char *p = str;
	char *s = str;
	char *e = str;
	int MaxNum = 0;
	int symmtry = 0;

	while(*(p + 1) != '\0')
	{
		if (*p == *(p + 1))
		{
			s = p;
			e = p + 1;

			symmtry = 0;
			while((*s == *e )&&(s>= str)&&(*e != '\0'))
			{
				symmtry += 2;
				s--;
				e++;				
			}
			if (symmtry > MaxNum)
				MaxNum = symmtry;

			
		}
		p++;
	}
	return MaxNum;
}




int main(int argc, char const *argv[])
{
	char str[] = "gogoo";
	if (isSymmtryStr(str))
	{
		printf("%s is a symmtry string\n", str);
		printf("its max symmtry string length is %d\n", findMaxSymmtryStr(str));
	}		
	else 
	{
		printf("%s isn't a symmtry string\n", str);
		printf("its max symmtry string length is %d\n", findMaxSymmtryStr(str));
	}
		
	return 0;
}